using System;
using System.Data;
using System.Collections.Generic;
using System.Text;

using PickGold;
using PickGold.Database;

namespace PickGold.Entities.Table
{
    public class CLogSessionInfo : CLogTable
    {
        //
        public const string ENTITY_NAME = "tl_sys_session_info";
        public const string ENTITY_ALIAS = "session_log";
        //
        public const string ONLINE_ID = CBaseUserOnline.ENTITY_KEY;
        public const string REMOTE_ADDR = "remote_addr";
        public const string HTTP_HOST = "http_host";
        public const string ACCEPT_LANGUAGE = "accept_language";
        public const string USER_AGENT = "user_agent";
        public const string UA_PIXELS = "ua_pixels";
        public const string UA_COLOR = "ua_color";
        public const string UA_OS = "ua_os";
        public const string UA_CPU = "ua_cpu";
        public const string UA_MEMORY = "ua_memory";
        public const string START_TIME = "start_time";
        //
        private SLogSessionInfo _ = null;
        //
        public CLogSessionInfo() : base(ENTITY_NAME, ENTITY_ALIAS) { }
        public CLogSessionInfo(CDatabase db) : base(db, ENTITY_NAME, ENTITY_ALIAS) { }
        public CLogSessionInfo(string alias) : base(ENTITY_NAME, alias) { }
        public CLogSessionInfo(CDatabase db, string alias) : base(db, ENTITY_NAME, alias) { }
        //
        protected override void SetSchema()
        {
            this.SetSchema(new SLogSessionInfo());
        }
        protected void SetSchema(SLogSessionInfo s)
        {
            this._ = s;
            base.SetSchema(s);
        }
        //
        protected override void PreInitSchema()
        {
            this._DataTable.Columns.Add(ONLINE_ID, typeof(long)).DefaultValue = this._.OnlineID;
            this._DataTable.Columns.Add(REMOTE_ADDR, typeof(long)).DefaultValue = this._.RemoteAddr;
            this._DataTable.Columns.Add(HTTP_HOST, typeof(string)).MaxLength = 100;
            this._DataTable.Columns.Add(ACCEPT_LANGUAGE, typeof(string)).MaxLength = 50;
            this._DataTable.Columns.Add(USER_AGENT, typeof(string)).MaxLength = 100;
            this._DataTable.Columns.Add(UA_PIXELS, typeof(string)).MaxLength = 50;
            this._DataTable.Columns.Add(UA_COLOR, typeof(string)).MaxLength = 50;
            this._DataTable.Columns.Add(UA_OS, typeof(string)).MaxLength = 50;
            this._DataTable.Columns.Add(UA_CPU, typeof(string)).MaxLength = 50;
            this._DataTable.Columns.Add(UA_MEMORY, typeof(string)).MaxLength = 50;
            this._DataTable.Columns.Add(START_TIME, typeof(DateTime)).DefaultValue = this._.StartTime;
        }
        //
        #region Property
        //
        public long OnlineID
        {
            set
            {
                this._.OnlineID = value;
                this.SetValue(ONLINE_ID, value);
            }
            get
            {
                return this._.OnlineID;
            }
        }
        //
        public long RemoteAddr
        {
            set
            {
                this._.RemoteAddr = value;
                this.SetValue(REMOTE_ADDR, value);
            }
            get
            {
                return this._.RemoteAddr;
            }
        }
        //
        public string HttpHost
        {
            set
            {
                this._.HttpHost = value;
                this.SetValue(HTTP_HOST, value);
            }
            get
            {
                return this._.HttpHost;
            }
        }
        //
        public string AcceptLanguage
        {
            set
            {
                this._.AcceptLanguage = value;
                this.SetValue(ACCEPT_LANGUAGE, value);
            }
            get
            {
                return this._.AcceptLanguage;
            }
        }
        //
        public string UserAgent
        {
            set
            {
                this._.UserAgent = value;
                this.SetValue(USER_AGENT, value);
            }
            get
            {
                return this._.UserAgent;
            }
        }
        //
        public string UaPixels
        {
            set
            {
                this._.UaPixels = value;
                this.SetValue(UA_PIXELS, value);
            }
            get
            {
                return this._.UaPixels;
            }
        }
        //
        public string UaColor
        {
            set
            {
                this._.UaColor = value;
                this.SetValue(UA_COLOR, value);
            }
            get
            {
                return this._.UaColor;
            }
        }
        //
        public string UaOs
        {
            set
            {
                this._.UaOs = value;
                this.SetValue(UA_OS, value);
            }
            get
            {
                return this._.UaOs;
            }
        }
        //
        public string UaCpu
        {
            set
            {
                this._.UaCpu = value;
                this.SetValue(UA_CPU, value);
            }
            get
            {
                return this._.UaCpu;
            }
        }
        //
        public string UaMemory
        {
            set
            {
                this._.UaMemory = value;
                this.SetValue(UA_MEMORY, value);
            }
            get
            {
                return this._.UaMemory;
            }
        }
        //
        public DateTime StartTime
        {
            set
            {
                this._.StartTime = value;
                this.SetValue(START_TIME, value);
            }
            get
            {
                return this._.StartTime;
            }
        }
        //
        #endregion
        //
        public override bool MoveTo(int position)
        {
            if (!base.MoveTo(position))
                return false;
            this._.OnlineID = this.GetValue<long>(ONLINE_ID);
            this._.RemoteAddr = this.GetValue<long>(REMOTE_ADDR);
            this._.HttpHost = this.GetValue<string>(HTTP_HOST);
            this._.AcceptLanguage = this.GetValue<string>(ACCEPT_LANGUAGE);
            this._.UserAgent = this.GetValue<string>(USER_AGENT);
            this._.UaPixels = this.GetValue<string>(UA_PIXELS);
            this._.UaColor = this.GetValue<string>(UA_COLOR);
            this._.UaOs = this.GetValue<string>(UA_OS);
            this._.UaCpu = this.GetValue<string>(UA_CPU);
            this._.UaMemory = this.GetValue<string>(UA_MEMORY);
            this._.StartTime = this.GetValue<DateTime>(START_TIME);
            return true;
        }
        //
    }
    //
    public class SLogSessionInfo : SLogTable
    {
        //
        public long OnlineID = -1;
        public long RemoteAddr = 0;
        public string HttpHost = null;
        public string AcceptLanguage = null;
        public string UserAgent = null;
        public string UaPixels = null;
        public string UaColor = null;
        public string UaOs = null;
        public string UaCpu = null;
        public string UaMemory = null;
        public DateTime StartTime = DateTime.MinValue;
        //
    }
    //
}
//
